#include <iostream>
#include <vector>
#include <queue>
using namespace std;

int main() {

    int n;
    cin>>n;
    priority_queue<int,vector<int>,greater<int>> q;
    for(int i=0;i<n;++i){
        int t;
        cin>>t;
        q.push(t);
    }
    int nRet=-1;
    while(q.size() && nRet==-1){
        int val=q.top();
        q.pop();
        if(q.size() && q.top()!=val || q.empty()){
            nRet=val;
        }
        else if(q.size()){
            while(q.size() && q.top()==val){
                q.pop();
            }
        }
    }
    cout<<nRet<<endl;

    return 0;
}
